<?php

include_once ('conn.php');

$sql = "select * from `department` order by `id`";

$pd = mysqli_query($conn,$sql);

if(!$pd){
    die("数据库失败！");
}

?>

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

<a href="useradd.php">新增</a>

    <table border="1" width="500" align="center">
        <tr><th>部门ID</th><th>部门名称</th><th>部门简介</th><th>操作</th></tr>
        <?php
        if(mysqli_num_rows($pd)<=0){
            echo "<tr align='center'><td colspan='4'>暂无数据！</td></tr>";
        }else{
        while($hh = mysqli_fetch_assoc($pd)){
            echo "<tr>";
            foreach ($hh as $item) {

                ?>
                <td align="center"><?php echo $item ?></td>


        <?php
               $id =  $hh['id'];
                }
        ?>
            <td><a href='update.php?id=<?php echo $id ?>'>更新</a> |
                <a href="delete.php?id=<?php echo $id ?>">删除</a> </td>
        <?php

        }
        }
        ?>

        </tr>
    </table>


</body>
</html>













